package com.agileboot.attendance.domain.settlement.mapper;

import com.agileboot.attendance.domain.settlement.dto.SettlementBillQuery;
import com.agileboot.attendance.domain.settlement.entity.AttSettlementEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 结算单Mapper接口
 */
@Mapper
public interface AttSettlementMapper extends BaseMapper<AttSettlementEntity> {

    /**
     * 获取指定前缀的最大单号
     *
     * @param prefix 单号前缀（年月）
     * @return 最大单号
     */
    @Select("SELECT bill_no FROM att_settlement WHERE bill_no LIKE CONCAT(#{prefix}, '%') ORDER BY bill_no DESC LIMIT 1")
    String getMaxBillNoByPrefix(@Param("prefix") String prefix);

    /**
     * 根据条件查询结算单列表
     *
     * @param query 查询条件
     * @return 结算单列表
     */
    List<AttSettlementEntity> selectSettlementList(@Param("query") SettlementBillQuery query);
} 